//
//  ChatViewController.m
//  used
//
//  Created by lanou on 16/7/26.
//  Copyright © 2016年 王凯. All rights reserved.
//

#import "ChatViewController.h"
#import "ChatRoomViewController.h"

@interface ChatViewController ()<CDChatListVCDelegate>

@property (nonatomic ,strong) UITextField *textField;

@end

@implementation ChatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    BmobUser *user = [BmobUser getCurrentUser];
    if (!user) {
        YSLLoginRegisterViewController *login = [[YSLLoginRegisterViewController alloc] init];
        [self presentViewController:login animated:YES completion:nil];
    }else {
        
        NSString *client = [user objectForKey:@"uname"]?[user objectForKey:@"uname"]:user.username;
        
        
        //获取帐号信息
        [[CDChatManager manager]openWithClientId:client callback:^(BOOL succeeded, NSError *error) {
            
        }];
        
    }
    self.chatListDelegate = self;

    self.navigationItem.title = @"消息";
    self.view.backgroundColor = KLRGBColor(240, 240, 240);
    
    // Do any additional setup after loading the view.
}



- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    //标签栏隐藏,防止遮住输入控件
//    self.navigationController.tabBarController.tabBar.hidden = NO;
}

- (void)viewController:(UIViewController *)viewController didSelectConv:(AVIMConversation *)conv {
    ChatRoomViewController *chatRoomVC = [[ChatRoomViewController alloc] initWithConversation:conv];
    [self.navigationController pushViewController:chatRoomVC animated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

